#!/usr/bin/env python3
"""
简单测试联系人搜索
"""

import requests
import json

# 配置
BASE_URL = "http://localhost:8000"

def test_simple_search():
    """简单测试搜索"""
    # 先登录
    login_data = {"username": "admin", "password": "admin123"}
    response = requests.post(f"{BASE_URL}/api/auth/login", json=login_data)
    
    if response.status_code != 200:
        print("登录失败")
        return
    
    token = response.json().get("access_token")
    headers = {"Authorization": f"Bearer {token}"}
    
    # 测试搜索
    print("测试搜索 '张三'...")
    response = requests.get(f"{BASE_URL}/api/contacts/search?q=张三&limit=10", headers=headers)
    print(f"响应状态: {response.status_code}")
    print(f"响应内容: {response.text}")

if __name__ == "__main__":
    test_simple_search()
